#ifndef __SW_PWM_H_H_
#define	__SW_PWM_H_H_

#include "stdint.h"

#ifdef	__cplusplus
extern "C" {
#endif

	typedef struct
	{
		uint32_t period_set;
		uint32_t duty_set;
		uint8_t en;
		
		uint32_t period_now;
		uint32_t duty_now;
		uint32_t cnt;
		uint8_t out;
	} sim_pwm_type;

	uint8_t sim_pwm_cal(sim_pwm_type * obj);

	typedef struct
	{
		uint32_t period_set;
		uint8_t * duty_set_list;
		uint8_t en;
		uint8_t duty_len;

		uint8_t * duty_now_list;
		uint8_t duty_index;
		uint8_t period_now;
		uint8_t duty_now;
		uint8_t cnt;

		uint8_t out;
	} sim_pwms_type;
	
	uint8_t sim_pwm_list_handle(sim_pwms_type * obj);
	
	void average_segmentation_u16(uint16_t dat, uint16_t amount, uint8_t *des);

	typedef struct
	{
		uint8_t en_mode;  
		uint8_t out;
		uint16_t period_set;
		uint8_t * duty_set_list; 

		uint8_t set_update_req;

		uint8_t * duty_now_list;
		uint16_t period_now;
		uint16_t cnt;
	} sim_elec_out_type;

	uint8_t sim_elec_out_list_handle(sim_elec_out_type * obj);
	void elec_site_average(uint8_t *list, uint16_t period, uint16_t val);

#ifdef	__cplusplus
}
#endif

#endif	

